package zzl.spider.app_01;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: zhangzeli
 * @date 14:58 2018/5/10
 * <P></P>
 */
public class T {
    public static void main(String[] args) throws Exception{
        URL url = new URL("http://www.163.com/");
        BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(url.openStream()), Charset.forName("gbk")));
        StringBuffer sb = new StringBuffer();
        String tmp ="";
        while ((tmp=br.readLine())!=null){
            sb.append(tmp);
        }

        String html = sb.toString();

       // Pattern compile = Pattern.compile("<a[^>]+href=[\"\\'](.*?)[\"\\.]>");
        Pattern compile = Pattern.compile("src=\"([\\w\\s.:/]+)\"");
        Matcher matcher = compile.matcher(html);
        while (matcher.find()){
            System.out.println(matcher.group(1));
        }
    }
}
